#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=1e7+7,N=1e7,mod=1e9+7;
int T;
ll n,f[Maxn];
int num[11];

int main(){
	freopen("give.in","r",stdin);
	freopen("give.out","w",stdout);
	for(int i=1;i<=N;i++){
		int x=i;
		while(x) num[x%10]++,x/=10;
		int mx=0,nn=0;
		for(int j=0;j<10;j++) if(num[j]>=mx) mx=num[j],nn=j;
		for(int j=0;j<10;j++) num[j]=0;
		f[i]=f[i-1]+nn; 
	}
	cin>>T;
	while(T--){
		cin>>n;
		cout<<f[n]%mod<<endl;
	}
	
	
	return 0;
}
/*
5
9
99
999
99999
999999
*/ 
